<extend name="Public/base"/>
<block name="body">
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <div class="main-title">
        <h2>{$meta_title}</h2>
    </div>

    <form action="" method="post" class="form-horizontal">

        <!--  图片  -->
        <div class="controls">
            <label class="item-label">图片<span class="check-tips">（推荐尺寸：750px * 360px）</span></label>
            <input type="file" id="img_file" style="display: none">
            <input type="hidden" name="img" id="img" value="{$info['img']|default=''}"/>
            <img class="upload-file" src="/Uploads/Picture/uploadBtn.png" id="uploadImg">
            <script type="text/javascript">
                $("#uploadImg").click(function (){
                    $("#img_file").trigger("click");
                })
                $('#img_file').change(function (){
                    var pic = $(this)[0].files[0];
                    var formData = new FormData();
                    var url="{:U('File/uploadPicture',array('session_id'=>session_id()))}";
                    formData.append('download', pic);
                    $.ajax({
                        url:url,
                        type:"post",
                        data: formData,
                        cache: false,
                        contentType: false,
                        processData: false,
                        success:function(data){
                            if(data.status == 1){
                                //上传成功
                                var id = data.id;
                                var path = data.path;

                                $('#img').val(id);
                                $('#uploadImg').attr('src', path);
                            }else{
                                layer.msg(data.info);
                            }
                        }
                    });
                });
            </script>
        </div>
        <!--  分类  -->
        <div class="form-item">
            <label class="item-label">分类</label>
            <div class="controls">
                <select name="type_id">
                    <option value="0">请选择图库分类</option>
                    <volist name="type_list" id="vo">
                        <option value="{$vo.id}">{$vo.name}</option>
                    </volist>
                </select>
            </div>
        </div>
        <!--  图片类型  -->
        <div class="form-item">
            <label class="item-label">图片类型</label>
            <div class="controls">
                <label><input class="style_radio" type="radio" name="style" value="0" checked /> 普通图片</label>
                <label><input class="style_radio" type="radio" name="style" value="1" /> 长期图片</label>
                <label><input class="style_radio" type="radio" name="style" value="2" /> 定期图片</label>
            </div>
        </div>
        <!--  时间范围  -->
        <div class="form-item time" style="display: none;">
            <label class="item-label">图片类型</label>
            <div class="controls">
                <input type="text" class="show_start_time text" name="show_start_time" placeholder="请选择开始时间" readonly>
                <input type="text" class="show_end_time text" name="show_end_time" placeholder="请选择结束时间" readonly>
            </div>
        </div>

        <input type="hidden" value="{:I('id')}" name="id" />
        <div class="form-item">
            <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
    <link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
    <link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
    <script type="text/javascript">
        $(function() {
            $('.show_start_time').datetimepicker({
                format: 'yyyy-mm-dd hh:ii',
                language: "zh-CN",
                minView: 0,
                minuteStep: 1,
                autoclose: true
            });
            $('.show_end_time').datetimepicker({
                format: 'yyyy-mm-dd hh:ii',
                language: "zh-CN",
                minView: 0,
                minuteStep: 1,
                autoclose: true
            });
        })

        $('.style_radio').change(function (){
            var style = $(this).val() ? $(this).val() : 0;

            if(style == 2){
                $('.time').show();
            }else{
                $('.time').hide();
                $('.show_start_time').val('');
                $('.show_end_time').val('');
            }
        })


        //导航高亮
        highlight_subnav('{:U("Manage/pictureGalleryList")}');
    </script>
</block>
</html>